<template>
  <div class="my-service bg-white mx-[20rpx] mt-[20rpx] rounded-lg">
    <!-- <div
            v-if="content.title_display"
            class="title px-[30rpx] py-[20rpx] font-medium text-xl border-light border-solid border-0 border-b"
        >
            <div>{{ content.title }}</div>
        </div> -->
    <div
      v-if="content.style === 1"
      class="flex flex-wrap pt-[40rpx] pb-[20rpx]"
    >
      <template
        v-for="(item, index) in content.data"
        :key="index"
        style="box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.72)"
      >
        <div
          v-if="
            item.name === '师傅订单'
              ? userInfo.staff
              : item.name === '个人优惠码'
              ? userInfo.salesman
              : item.name === '发起团购'
              ? userInfo.salesman
              : item.name === '包年服务预约'
              ? userInfo.annualService
              : true
          "
          class="flex flex-col items-center w-1/4 mb-[15px]"
          @click="handleClick(item.link)"
        >
          <u-image
            width="52"
            height="52"
            :src="getImageUrl(item.image)"
            alt=""
          />
          <div class="mt-[7px]">{{ item.name }}</div>
        </div>
      </template>
    </div>
    <div v-if="content.style === 2">
      <template
        v-for="(item, index) in content.data"
        :key="index"
        style="box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.72)"
      >
        <div
          v-if="
            item.name === '师傅订单'
              ? userInfo.staff
              : item.name === '个人优惠码'
              ? userInfo.salesman
              : item.name === '发起团购'
              ? userInfo.salesman
              : item.name === '包年服务预约'
              ? userInfo.annualService
              : true
          "
          class="flex items-center border-light border-solid border-0 border-b h-[100rpx] px-[24rpx]"
          @click="handleClick(item.link)"
        >
          <u-image
            width="48"
            height="48"
            :src="getImageUrl(item.image)"
            alt=""
          />
          <div class="ml-[20rpx] flex-1">{{ item.name }}</div>
          <div class="text-muted">
            <u-icon name="arrow-right" />
          </div>
        </div>
      </template>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useAppStore } from "@/stores/app";
import { navigateTo } from "@/utils/util";
import { useUserStore } from "@/stores/user";
import { storeToRefs } from "pinia";

const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);

const props = defineProps({
  content: {
    type: Object,
    default: () => ({}),
  },
  styles: {
    type: Object,
    default: () => ({}),
  },
});

const { getImageUrl } = useAppStore();
const handleClick = (link: any) => {
  console.log(link, "link");
  navigateTo(link);
};

console.log("userInfo", userInfo.value);
</script>

<style lang="scss">
.border-b {
  border-bottom-width: 1rpx !important;
}
</style>
